﻿@model Kojarskiy.Core.SmtpSettings

<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script>

<table class="cmsTable">
<tr>
    <td style="width: 20%">
        <div class="header" style="text-align: left;">Хост</div>
    </td>
    <td>
        <div class="text wide">
        @Html.EditorFor(model => model.SmtpHost)
        @Html.ValidationMessageFor(model => model.SmtpHost)
        </div>
    </td>
    <td colspan="2">
        <div class="header" style="text-align: left;" onclick="SelectCridentials();">
        @Html.EditorFor(model => model.UseDefaultCredentials)  
        Аутентификация по умолчанию</div>
    </td>
</tr>
<tr>
    <td style="width: 20%">
        <div class="header" style="text-align: left;">Порт</div>
    </td>
    <td>
        <div class="text wide">
            @Html.EditorFor(model => model.SmtpPort)
        </div>
    </td>
    <td colspan="2" style="padding-left: 30px;">
       <div>
            Пользователь
       </div>
       <div class="wide">
            @Html.EditorFor(model => model.SmtpUser)
            @Html.ValidationMessageFor(model => model.SmtpUser)
       </div>
    </td>
</tr>
<tr>
    <td colspan="2">
       <div class="header" style="text-align: left;">@Html.EditorFor(model => model.EnableSsl) Включить SSL</div>
    </td>
    <td colspan="2" style="padding-left: 30px;">
       <div>
            Пароль
       </div> 
       <div class="wide">
            @Html.EditorFor(model => model.SmtpPassword)
            @Html.ValidationMessageFor(model => model.SmtpPassword)    
       </div>
    </td>
</tr>
<tr>
    <td>
       <div class="header" style="text-align: left;">Email админа</div>
    </td>
    <td>
       <div class="wide">
            @Html.EditorFor(model => model.AdminEmail)
            @Html.ValidationMessageFor(model => model.AdminEmail)    
       </div> 
    </td>
    <td colspan="2">
    
    </td>
</tr>
</table>
<script type="text/javascript">
    
    function SelectCridentials() 
    {
        if ($("#UseDefaultCredentials").attr('checked')) 
        {
            $("#SmtpUser").attr('disabled', 'disabled');
//            $("#SmtpUser").val('');
            $("#SmtpPassword").attr('disabled', 'disabled');
//            $("#SmtpPassword").val('');
        }
        else {
            $("#SmtpUser").attr('disabled', '');
            $("#SmtpPassword").attr('disabled', '');         
        }
    }
</script>
